home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / overview / dtscpluslibrary / headers / template.h < prev    next >
Encoding:
Text File  |  2000-06-23  |  4.2 KB  |  123 lines

  1. /*
  2.     File:        Template.h
  3.  
  4.     Contains:    
  5.  
  6.     Written by: Kent Sandvik    
  7.  
  8.     Copyright:    Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 8/18/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23. // ••• Define the label so the file will be included only once. Note that 
  24. // ••• we use only one _ instead of two in order to conform to the ANSI specs. 
  25. // ••• Also don't forget the last #endif at the end of the file!
  26.  
  27. #ifndef _FOO_
  28. #define _FOO_
  29.  
  30. // ••• This is the only header file we always need to include, it contains the 
  31. // ••• global headers, structures and functions for all classes.
  32. #ifndef _DTSCPLUSLIBRARY_
  33. #include "DTSCPlusLibrary.h"
  34. #endif
  35.  
  36. // ••• Specify below all the needed Macintosh toolbox interfaces - don't just 
  37. // ••• include one file and assume that this file will include more files. 
  38. // ••• Each header file should be self-contained. 
  39. //    Toolbox Include Files
  40. #ifndef __PROCESSES__
  41. #include <Processes.h>
  42. #endif
  43.  
  44. #ifndef __APPLEEVENTS__
  45. #include <AppleEvents.h>
  46. #endif
  47.  
  48.  
  49. // ••• Specify any global structures and enums/typedefs here
  50. // Global structures, typdefs and enums
  51.  
  52. const ProcessSerialNumber kMyProcess = {
  53.                                         kNoProcess, kNoProcess};
  54.  
  55.  
  56. // ••• Here is the start of the class definition. Each file should only have
  57. // ••• one class definition, unless we are dealing with really small classes.
  58. // ••• Why are all member functions virtual? It's for SLM support, and developers could change this easily.
  59. // _________________________________________________________________________________________________________ //
  60. //    TFoo Class Interface
  61.  
  62. class TFoo
  63. {
  64.     // ••• Provide information about the TFoo class here - this because using a browser we 
  65.     // ••• will have information needed concerning how to use the class.
  66. public:
  67.     // ••• This section will contain any class specific typedefs and enums. The reason 
  68.     // ••• it's the first section has to do with C++, you need to specify enums and 
  69.     // ••• typedefs before using them…
  70.     //     TYPEDEFS AND ENUMS
  71.     enum EConstants
  72.     {
  73.         kFirstThing = 1, kLastThing = 999
  74.     };
  75.  
  76.     // ••• Here we will specify all the constructors and destructors needed 
  77.     //    CONSTRUCTORS & DESTRUCTOR
  78.     TFoo();                                        // default constructors
  79.     virtual~ TFoo();                            // virtual destructor
  80.  
  81.     // ••• This section will contain the main interfaces to the class itself.
  82.     //  MAIN INTERFACE
  83.     virtual Boolean KillApplication(ProcessSerialNumber*);// quit the application
  84.     virtual short GetNumProcesses();            // get the N amount of currently running procs
  85.  
  86.     // ••• This section will contain the get and set member functions.
  87.     //    PUBLIC ACCESSORS AND MUTATORS    
  88.     virtual ProcessSerialNumber GetMyProcessID() const;
  89.  
  90.     // ••• This section will contain possible iterators, note the keywords Next, Last, First and Reset.
  91.     // ITERATORS
  92.     virtual void Next();                        // next PSN
  93.     virtual Boolean Last();                        // last PSN?
  94.     virtual void First();                        // first PSN
  95.     virtual void Reset();                        // reset the list to the last entry
  96.  
  97.     //    ••• This section will contain fields inside the class.
  98.     //    FIELDS
  99. protected:
  100.     ProcessSerialNumber fProcessID;                // any specific PSN number
  101.     ProcessSerialNumber fMyProcessID;            // our PSN number
  102.     ProcessSerialNumber fFirstPSN;                // the first one we got
  103.     Boolean fFirstTime;                            // signals order of iterators
  104.     Boolean fLast;                                // used to signal last process in an iterator list
  105. private:
  106.     Boolean fState;                                // state of the object
  107.     OSErr fError;                                // latest toolbox error
  108. };
  109.  
  110.  
  111. #endif
  112.  
  113. // _________________________________________________________________________________________________________ //
  114.  
  115.  
  116. /*    Change History (most recent last):
  117.   No        Init.    Date        Comment
  118.   1            khs        6/10/92        New file
  119.   2            khs        7/6/92        First decent working class
  120. */
  121.  
  122.  
  123.